#pragma once
#ifndef __GLF_DEBUGGER_CONSOLE_H__
#define __GLF_DEBUGGER_CONSOLE_H__

#include <glf/config.h>

#if GLF_ENABLE_DEBUGGER

#include <glf/debugger/debugger.h>
#include <vector>

namespace glf
{
namespace debugger
{

class Console : public Module
{
	GLF_DECLARE_SINGLETON_WITH_DEP(Console, Debugger)
public:
	virtual ~Console();

	enum Color
	{
		BLACK = 0xff000000
	};

	static void Print(const char* str, const char* consoleID = "", uint color = BLACK);
	static void VPrintf(const char* consoleID, uint color, const char* fmt, glfVaList argp);
	static void VPrintf(const char* consoleID, const char* fmt, glfVaList argp);
	static void VPrintf(const char* fmt, glfVaList argp);
	static void Printf(const char* consoleID, uint color, const char* fmt, ...);
	static void Printf(const char* consoleID, const char* fmt, ...);
	static void Printf(const char* fmt, ...);
	static void Clear(const char* consoleID);

private:
	Console();
	

	enum MessageType
	{
		// Glf to Debugger
		MESSAGE_LOGS
	};

	virtual void UpdateFrame();
	void SendLogs();

	struct Entry
	{
		Entry(const char* str, const char* consoleID, uint color, uint64 timeStamp) :
			mStr(str),
			mConsoleID(consoleID),
			mColor(color),
			mTimeStamp(timeStamp)
		{
			// if(this->str.size() > 0 && this->str[this->str.size() - 1] != '\n')
			this->mStr += "\n";
		}

		stringdbg mStr;
		stringdbg mConsoleID;
		uint mColor;
		uint64 mTimeStamp;
	};

	std::vector<Entry, DebuggerAllocator<Entry> > mPendingLogs;
};

} // end namespace debugger
} // end namespace glf

#endif // GLF_ENABLE_DEBUGGER

#endif
